/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Game;

import Cards.Card;
import Cards.Deck;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;

/**
 * Class Game. It can use to manage any Game with a deck, players and deque of playedCards
 * @author escabia
 */
public class Game<C extends Card, P extends Player> {
    protected Deck<C> deck; //Baraja
    protected final ArrayList<P> players; //Contiene los jugadores
    protected final Deque<C> playedCards;//stack of already played cards

    
    /**
     * Method to initialize Game
     */
    public Game(){
        players = new ArrayList<>();
        deck = new Deck<>();
        playedCards = new ArrayDeque<>();
    }
    
    /**
     * Method to get deck
     * @return 
     */
    public Deck<C> getDeck(){
        return deck;
    }
    
    /**
     * Method to get top card
     * @return card
     */
    public C getTopCard(){
        return playedCards.getFirst(); //no elimina la primera carta de la pila
    }
    
    /**
     * Method to set top card
     * @param card 
     */
    public void setTopCard(C card){ //Introduce una carta en la parte de arriba de la pila
        playedCards.push(card);
    }
    
    /**
     * Method to get first on deck
     * @return card
     */
    public C getFirstOnDeck(){ //Recupera la primera carta de la baraja y la elimina de ella
        return deck.takeCard();
    }
    
    /**
     * Method to get if deck is empty
     * @return true if empty
     */
    public boolean emptyDeck(){
        return deck.isEmpty();
    }
}
